<?php
require_once './libs/Certificates.php';
$Certificates=new Certificates();
$cert_sn=$Certificates->get('serial_no');
//获取平台证书序列号

?>

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>申请入驻</title>
    <style>
        .input-container{
            margin-bottom: 10px;
        }
        .input-container label{
            width: 100px;
            text-align: right;
        }
        .input-container input,.input-container textarea{
            width: 300px;
        }
    </style>
</head>
<body>
    <form action="./libs/Apply.php" method="post">
        <div class="input-container">
            <label>接口版本号</label>
            <input type="text" name="version" value="3.0">
        </div>
        <div class="input-container">
            <label>随机字符串</label>
            <input type="text" name="nonce_str" value="<?php echo md5(time());?>">
        </div>
        <div class="input-container">
            <label>签名类型</label>
            <input type="text" name="sign_type" value="HMAC-SHA256">
        </div>
        <div class="input-container">
            <label>平台证书序列号</label>
            <input type="text" name="cert_sn" value="<?php echo $cert_sn;?>">
        </div>
        <div class="input-container">
            <label>业务申请编号</label>
            <input type="text" name="business_code" value="<?php echo time();?>">
        </div>
        <div class="input-container">
            <label>商户号</label>
            <input type="text" name="mch_id" value="1364019302">
        </div>
        <div class="input-container">
            <label>身份证人像面照片</label>
            <input type="file" onchange="uploadImage(this,'id_card_copy')">
            <input type="hidden" name="id_card_copy" value="">
        </div>
        <div class="input-container">
            <label>身份证国徽面照片</label>
            <input type="file" onchange="uploadImage(this,'id_card_national')">
            <input type="hidden" name="id_card_national" value="">
        </div>
        <div class="input-container">
            <label>身份证姓名</label>
            <input type="text" name="id_card_name" value="杨信琼">
        </div>
        <div class="input-container">
            <label>身份证号码</label>
            <input type="text" name="id_card_number" value="510229197309157483">
        </div>
        <div class="input-container">
            <label>身份证有效期限</label>
            <input type="text" name="id_card_valid_time" value='["2007-02-28","2027-02-28"]'>
        </div>
        <div class="input-container">
            <label>开户名称</label>
            <input type="text" name="account_name" value="杨信琼">
        </div>
        <div class="input-container">
            <label>开户银行</label>
            <input type="text" name="account_bank" value="其他银行">
        </div>
        <div class="input-container">
            <label>开户银行省市编码</label>
            <input type="text" name="bank_address_code" value="500118">
        </div>
        <div class="input-container">
            <label>开户银行全称（含支行）</label>
            <input type="text" name="bank_name" value="成都银行股份有限公司重庆永川支行">
        </div>
        <div class="input-container">
            <label>银行账号</label>
            <input type="text" name="account_number" value="6221532322100423483">
        </div>
        <div class="input-container">
            <label>门店名称</label>
            <input type="text" name="store_name" value="乡村豆花">
        </div>
        <div class="input-container">
            <label>门店省市编码</label>
            <input type="text" name="store_address_code" value="500118">
        </div>
        <div class="input-container">
            <label>门店街道名称</label>
            <textarea name="store_street" cols="30" rows="2">重庆市永川区和顺大道364号</textarea>
        </div>
        <div class="input-container">
            <label>门店门口照片</label>
            <input type="file" onchange="uploadImage(this,'store_entrance_pic')">
            <input type="hidden" name="store_entrance_pic" value="">
        </div>
        <div class="input-container">
            <label>店内环境照片</label>
            <input type="file" onchange="uploadImage(this,'indoor_pic')">
            <input type="hidden" name="indoor_pic" value="">
        </div>
        <div class="input-container">
            <label>商户简称</label>
            <input type="text" name="merchant_shortname" value="乡村豆花">
        </div>
        <div class="input-container">
            <label>客服电话</label>
            <input type="text" name="service_phone" value="17898695193">
        </div>
        <div class="input-container">
            <label>售卖商品/提供服务描述</label>
            <input type="text" name="product_desc" value="其他">
        </div>
        <div class="input-container">
            <label>费率</label>
            <input type="text" name="rate" value="0.6%">
        </div>
        <div class="input-container">
            <label>联系人姓名</label>
            <input type="text" name="contact" value="杨信琼">
        </div>
        <div class="input-container">
            <label>手机号码</label>
            <input type="text" name="contact_phone" value="17898695193">
        </div>
        <input type="submit" value="提交">
    </form>
</body>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="./assets/js/upload_image.js"></script>
<script type="text/javascript">
    function uploadImage(obj,name) {
        var formData = new FormData();
        formData.append("file", $(obj).get(0).files[0]);
        formData.append("mch_id", $('input[name="mch_id"]').val());
        window.UploadImage({
            url:"./libs/UploadImage.php",
            data:formData,
            callback:function (info) {
                info=JSON.parse(info);
                console.log(info);
                if(info.errorCode===0){
                    $('input[name="'+name+'"]').val(info.data.media_id);
                }else {
                    alert(info.msg);
                }
            }
        });
    }
</script>
</html>
